import pygame
import time
from pygame.sprite import Sprite
# from main import AlienInvasion


class NormalAlien(Sprite):
    def __init__(self, game, i, j):  # : AlienInvasion
        super().__init__()
        self.time_changed = time.time()
        self.main = game
        self.image = pygame.image.load('_image/normal_alien.png').convert()
        self.rect = self.image.get_rect()
        self.rect.x = self.rect.width + (40 * j) + (20 * j)
        self.rect.y = self.rect.height - (60 * (i+1)) - (20 * i)
        self.x = self.rect.x
        self.y = self.rect.y
        self.horizontal_direction = 1  # 1 for right, -1 for left
        self.move_speed_on_x = 1
        self.move_speed_on_y = 0.5
        self.health = 5

    def update(self):
        self.x += self.horizontal_direction * self.move_speed_on_x
        self.rect.x = self.x
        self.y += self.move_speed_on_y
        self.rect.y = self.y

    def check_edges(self) -> bool:
        main_screen_rect = self.main.screen_rect
        if self.rect.right >= main_screen_rect.right or self.rect.left <= main_screen_rect.left:
            return True
        else:
            return False
